# 导包
import unittest
from api.home import HomeAPI


# 创建测试类
class TestHomeAPI(unittest.TestCase):

    # 前置处理
    def setUp(self) -> None:
        self.home_api = HomeAPI()

    # 后置处理

    # 测试轮播图
    def test01_banner(self):
        response = self.home_api.get_banner()
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertEqual("首页轮播图", response.json().get("description"))

    # 测试专题栏位
    def test02_theme(self):
        response = self.home_api.get_theme()
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertIn("name", response.text)

    # 测试最近新品
    def test03_recent(self):
        response = self.home_api.get_recent()
        print(response.json())
        # 断言
        self.assertEqual(200, response.status_code)
        self.assertIn("name", response.text)

























































